feat: refs #7936 add SiiTypeInvoiceIn model and update invoice correction logic
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-27 17:52:45 +01:00
parent 4bb3305704
commit ba51052d88
8 changed files with 56 additions and 12 deletions

View File

@ -207,7 +207,7 @@ BEGIN
IF vInvoiceInOriginalFk THEN IF vInvoiceInOriginalFk THEN
UPDATE movContaIVA mci UPDATE movContaIVA mci
JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk
JOIN vn.siiTypeInvoiceOut st ON st.id = iic.siiTypeInvoiceOutFk JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk
JOIN (SELECT issued, JOIN (SELECT issued,
SUM(sub.taxableBase) taxableBase, SUM(sub.taxableBase) taxableBase,
SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat

View File

@ -0,0 +1,23 @@
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('SiiTypeInvoiceIn', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson');
DROP TABLE IF EXISTS vn.invoiceInCorrection;
CREATE TABLE `invoiceInCorrection` (
`correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa',
`correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada',
`cplusRectificationTypeFk` int(10) unsigned NOT NULL,
`siiTypeInvoiceInFk` int(10) unsigned NOT NULL,
`invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3,
PRIMARY KEY (`correctingFk`),
KEY `invoiceInCorrection_correctedFk` (`correctedFk`),
KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`),
KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`),
KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`),
CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

View File

@ -44,7 +44,7 @@ module.exports = Self => {
correctingFk: clone.id, correctingFk: clone.id,
correctedFk: id, correctedFk: id,
cplusRectificationTypeFk: invoiceType, cplusRectificationTypeFk: invoiceType,
siiTypeInvoiceOutFk: invoiceClass, siiTypeInvoiceInFk: invoiceClass,
invoiceCorrectionTypeFk: invoiceReason invoiceCorrectionTypeFk: invoiceReason
}, myOptions); }, myOptions);

View File

@ -30,7 +30,7 @@ describe('invoiceIn corrective()', () => {
}, options); }, options);
expect(correction.cplusRectificationTypeFk).toEqual(invoiceType); expect(correction.cplusRectificationTypeFk).toEqual(invoiceType);
expect(correction.siiTypeInvoiceOutFk).toEqual(invoiceClass); expect(correction.siiTypeInvoiceInFk).toEqual(invoiceClass);
expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason); expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason);
}); });
}); });

View File

@ -28,11 +28,10 @@
"model": "InvoiceCorrectionType", "model": "InvoiceCorrectionType",
"foreignKey": "invoiceCorrectionTypeFk" "foreignKey": "invoiceCorrectionTypeFk"
}, },
"siiTypeInvoiceOut": { "siiTypeInvoiceIn": {
"type": "belongsTo", "type": "belongsTo",
"model": "SiiTypeInvoiceOut", "model": "SiiTypeInvoiceIn",
"foreignKey": "siiTypeInvoiceOutFk" "foreignKey": "siiTypeInvoiceInFk"
} }
} }
} }

View File

@ -43,5 +43,8 @@
}, },
"SiiTypeInvoiceOut": { "SiiTypeInvoiceOut": {
"dataSource": "vn" "dataSource": "vn"
},
"SiiTypeInvoiceIn": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,22 @@
{
"name": "SiiTypeInvoiceIn",
"base": "VnModel",
"options": {
"mysql": {
"table": "siiTypeInvoiceIn"
}
},
"properties": {
"id": {
"id": true,
"type": "number",
"description": "Identifier"
},
"code": {
"type": "string"
},
"description": {
"type": "string"
}
}
}

View File

@ -17,9 +17,6 @@
}, },
"description": { "description": {
"type": "string" "type": "string"
},
"code": {
"type": "string"
} }
} }
} }