diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index 6f63c62..242e8ab 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -186,7 +186,7 @@ namespace Back.Controllers #region Inital Send InvoiceHeaderDto header = new InvoiceHeaderDto(); - + PreparationHeaderTaxInvoice preparation = new PreparationHeaderTaxInvoice(result, _actionTaxPayer); int level = result.pattern.ID; @@ -196,84 +196,110 @@ namespace Back.Controllers header = new InvoiceHeaderDto { //شماره منحصر به فرد مالیاتی - Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()), + Taxid = preparation.Taxid, //زمان صدور - Indatim = result.indatim ?? null, + Indatim = preparation.Indatim, //زمان ایجاد - Indati2m = result.Indati2m ?? null, + Indati2m = preparation.Indati2m, // صورتحساب نوع * - Inty = result.inty ?? 1, + Inty = preparation.Inty, //سریال صورت حساب - Inno = string.IsNullOrEmpty(result.inno) ? null : result.inno, + Inno = preparation.Inno, //شماره منحصر به فرد مالیاتی صورتحساب مرجع - Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid - : result.invoiceType == InvoiceType.Cancellation ? result.taxid : null, + Irtaxid = preparation.Irtaxid, //الگوی صورتحساب * - Inp = result.inp ?? 1, + Inp = preparation.Inp, //موضوع صورتحساب * - Ins = result.ins ?? 1, + Ins = preparation.Ins, //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد - Tins = string.IsNullOrEmpty(result.tins) ? null : result.tins, + Tins = preparation.Tins, //نوع شخص خریدار - Tob = level == 10 ? null : result.tob==5 ? 1 : result.tob==6 ? 4 : result.tob, + Tob = preparation.Tob, //شماره/شناسه ملی/شناسه مشارکت مدنی / کد فراگیر - Bid = level == 10 || string.IsNullOrEmpty(result.bid) || !string.IsNullOrEmpty(result.tinb) - || result.tob == 1 || result.tob == 2 || result.tob == 3 || result.tob == 4 ? null : result.bid, + Bid = preparation.Bid, //شماره اقتصادی خریدار - Tinb = level == 10 || string.IsNullOrEmpty(result.tinb) || result.tob == 5 || result.tob == 6 ? null : result.tinb, + Tinb = preparation.Tinb, //کد شعبه فروشنده - Sbc = string.IsNullOrEmpty(result.sbc) ? null : result.sbc, + Sbc = preparation.Sbc, //کد پستی خریدار - Bpc = level == 10 || string.IsNullOrEmpty(result.bpc) || !string.IsNullOrEmpty(result.tinb) - || result.tob == 1 || result.tob == 2 || result.tob == 3 || result.tob == 4 ? null : result.bpc, + Bpc = preparation.Bpc, //کد شعبه خریدار - Bbc = level == 10 || string.IsNullOrEmpty(result.bbc) ? null : result.bbc, + Bbc = preparation.Bbc, //نوع پرواز - Ft = level == 9 ? result.ft : null, + Ft = preparation.Ft, //شماره گذرنامه خریدار - Bpn = (level == 9 || level == 4) && !string.IsNullOrEmpty(result.bpn) ? result.bpn : null, + Bpn = preparation.Bpn, //شماره پروانه گمرکی - Scln = (level == 3 || level == 4) && !string.IsNullOrEmpty(result.scln) ? result.scln : null, + Scln = preparation.Scln, //کد گمرک محل اظهار فروشنده - Scc = (level == 3 || level == 4 || level == 10) && !string.IsNullOrEmpty(result.scc) ? result.scc : null, + Scc = preparation.Scc, //شماره کدتاژ اظهارنامه گمرکی - Cdcn = level == 10 ? result.cdcn : null, + Cdcn = preparation.Cdcn, //تاریخ کوتاژ اظهارنامه گمرکی - Cdcd = level == 10 ? result.cdcd : null, + Cdcd = preparation.Cdcd, //شناسه یکتای ثبت قزارداد فروشنده - Crn = (level == 3 || level == 4 || level == 5 || level == 6) && !string.IsNullOrEmpty(result.crn) ? result.crn : null, + Crn = preparation.Crn, //شماره اشتراک/شناسه قبض بهره بردار - Billid = level == 8 ?result.billid:null, + Billid = preparation.Billid, //مجموع مبلغ قبل از کسر تخفیف - Tprdis = level == 10 ? null : result.tprdis ?? null, + Tprdis = preparation.Tprdis, //مجموع تخفیفات - Tdis = level == 10 ? null : result.tdis ?? null, + Tdis = preparation.Tdis, // مجموع مبلغ پس از کسر تخفیف - Tadis = level == 10 ? null : result.tadis ?? null, + Tadis = preparation.Tadis, //مجموع مالیات بر ارزش افزوده - Tvam = result.tvam ?? null, + Tvam = preparation.Tvam, // مجموع سایر مالیات، عوارض و وجوه قانونی - Todam = result.todam ?? null, + Todam = preparation.Todam, //صورتحساب مجموع - Tbill = result.tbill ?? null, + Tbill = preparation.Tbill, //مجموع وزن خالض - Tonw = level == 10 ? result.tonw : null, + Tonw = preparation.Tonw, //مجموع ارزش ریالی - Torv = level == 10 ? result.torv : null, + Torv = preparation.Torv, //مجموع ارزش ارزی - Tocv = level == 10 ? result.tocv : null, + Tocv = preparation.Tocv, // تسویه روش - Setm = level == 8|| level == 10|| level == 11|| level == 13 || result.setm == 0 ? null : result.setm ?? null, + Setm = preparation.Setm, //نقدی پرداختی مبلغ - Cap = level == 8 || level == 10 || level == 11 || level == 13 ?null : result.cap ?? null, + Cap = preparation.Cap, //پرداختی نسیه - Insp = level == 8 || level == 10 || level == 11 || level == 13 ? null : result.insp ?? null, + Insp = preparation.Insp, //مجموع سهم مالیات بر ارزش افزوده از پرداخت - Tvop = level == 8 || level == 10 || level == 11 || level == 13 ? null : result.tvop ?? null, + Tvop = preparation.Tvop, //مالیات موضوع 17 - Tax17 = level == 10 || string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax), + Tax17 = preparation.Tax17, //شماره اقتصادی آژانس - Tinc = level == 9 && !string.IsNullOrEmpty(result.tinc) ? result.tinc : null + Tinc = preparation.Tinc, + //تاریخ اعلامیه فروش + Asd=null, + //شماره اعلامیه فروش + Asn = null, + //شماره ناوگان + Cno=null, + //شهر مقصد + Dci = null, + //کشور مقصد + Dco = null, + //کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای( + Did = null, + //شماره بارنامه + Lno = null, + //شماره بارنامه مرجع + Lrno = null, + //نوع بارنامه/ نوع حمل + Lt = null, + //شهر مبدا + Oci = null, + //کشور مبدا + Ocu = null, + //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده + Rid = null, + //کالاهای حمل شده + Sg = new List(), + //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی / کد فراگیر اتباع غیر ایرانی فرستنده + Tid =null + }; #endregion header @@ -285,74 +311,77 @@ namespace Back.Controllers foreach (var bitem in result.invoiceDetails) { InvoiceBodyDto item = new InvoiceBodyDto(); + PreparationBodyTaxInvoice preparationBody = new PreparationBodyTaxInvoice(bitem, level); #region body item = new InvoiceBodyDto { //شناسه کالا / خدمت - Sstid = bitem.sstid, + Sstid = preparationBody.Sstid, //شرح کاال/خدمت - Sstt = bitem.sstt, + Sstt = preparationBody.Sstt, // تعداد - Am = level==4 ?null: bitem.am, + Am = preparationBody.Am, //واحد اندازه گیری - Mu = level == 4 || string.IsNullOrEmpty(bitem.mu) ? null : bitem.mu, + Mu = preparationBody.Mu, //وزن خالص - Nw=level==10 ? bitem.nw : null, + Nw= preparationBody.Nw, // مبلغ واحد - Fee = level == 4 ? null : bitem.fee, + Fee = preparationBody.Fee, //میزان ارز - Cfee = bitem.cfee == 0|| level ==8 || level==10 ?null: bitem.cfee , + Cfee = preparationBody.Cfee , //نوع ارز - Cut = level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut, + Cut = preparationBody.Cut, //نرخ برابری ارز با ریال - Exr = level == 8 ?null: bitem.exr, + Exr = preparationBody.Exr, // ارزش ریالی کاا - Ssrv= level == 10 ?bitem.ssrv : null, + Ssrv= preparationBody.Ssrv, // ارزش ارزی کاا - Sscv= level == 10 ? bitem.sscv : null, + Sscv= preparationBody.Sscv, //مبلغ قبل از تخفیف - Prdis = level == 10 ? null : bitem.prdis, + Prdis = preparationBody.Prdis, //مبلغ تخفیف - Dis = level == 10 ? null : bitem.dis, + Dis = preparationBody.Dis, //مبلغ بعد از تخفیف - Adis = level == 10 ? null : bitem.adis, + Adis = preparationBody.Adis, //نرخ مالیات بر ارزش افزوده - Vra = bitem.vra, + Vra = preparationBody.Vra, //مبلغ مالیات بر ارزش افزوده - Vam = bitem.vam, + Vam = preparationBody.Vam, //موضوع سایر مالیات و عوارض - Odt = string.IsNullOrEmpty(bitem.odt) ? null : bitem.odt, + Odt = preparationBody.Odt, //نرخ سایر مالیات و عوارض - Odr = bitem.odr, + Odr = preparationBody.Odr, //مبلغ سایر مالیات و عوارض - Odam = bitem.odam, + Odam = preparationBody.Odam, //موضوع سایر وجوه قانونی - Olt = string.IsNullOrEmpty(bitem.olt) ? null : bitem.olt, + Olt = preparationBody.Olt, //نرخ سایر وجوه قانونی - Olr = bitem.olr, + Olr = preparationBody.Olr, //مبلغ سایر وجوه قانونی - Olam = bitem.olam, + Olam = preparationBody.Olam, //اجرت ساخت - Consfee = level ==5 || level ==13 ?bitem.consfee : null, + Consfee = preparationBody.Consfee, // سود فروشنده - Spro= level == 5 || level == 13 ? bitem.spro : null, + Spro= preparationBody.Spro, //حقالعمل - Bros= level == 5 || level == 13 ? bitem.bros : null, + Bros= preparationBody.Bros, //جمع کل اجرت، حقالعمل و سود - Tcpbs= level == 5 || level == 13 ? bitem.tcpbs : null, + Tcpbs= preparationBody.Tcpbs, //سهم نقدی از پرداخت - Cop = level==8 ||level==10 ||level==11||level==13 ? null : bitem.cop, + Cop = preparationBody.Cop, //سهم مالیات بر لرزش افزوده از پرداخت - Vop = level == 8 || level == 10 || level == 11 || level == 13 ? null : bitem.vop, + Vop = preparationBody.Vop, //شناسه یکتای ثبت قرارداد حق العمل کاری - Bsrn = string.IsNullOrEmpty(bitem.bsrn) ? null : bitem.bsrn, + Bsrn = preparationBody.Bsrn, // مبلغ کل کالا / خدمت - Tsstam = bitem.tsstam, - //فاوت نرخ خرید و فروش ارز/ کارمزد فروش ارز - // Pspd=level==4 ?bitem.pspd: null, + Tsstam = preparationBody.Tsstam, //عیار - Cui =level==5||level==13?bitem.cui: null + Cui = preparationBody.Cui, + // نرخ خرید ارز + Cpr = preparationBody.Cpr, + //ماخذ مالیات بر ارزش افزوده در الگوی فروش ارز + Sovat = preparationBody.Sovat }; #endregion InvoiceBody.Add(item); diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs index 57b49f5..09c2b01 100644 --- a/Back/Data/Models/Invoice.cs +++ b/Back/Data/Models/Invoice.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; using Back.Common; using Shared.DTOs; +using TaxCollectData.Library.Dto.Content; namespace Back.Data.Models { public class Invoice : ICloneable @@ -147,7 +148,7 @@ namespace Back.Data.Models { get { - return pattern.BillTypeID == 3 || pattern.BillTypeID == 4 || pattern.ID == 2 || pattern.ID == 10 + return pattern.BillTypeID == 3 || (pattern.BillTypeID == 2 && pattern.ID == 10) ? 1 : _setm; } @@ -170,6 +171,46 @@ namespace Back.Data.Models //شماره اقتصادی آژانس [MaxLength(14)] public string? tinc { get; set; } + //شماره بارنامه + [MaxLength(18)] + public string? ino { get; set; } + //شماره بارنامه مرجع + [MaxLength(18)] + public string? irno { get; set; } + //کشور مبدا + [MaxLength(3)] + public string? ocu { get; set; } + //شهر مبدا + [MaxLength(5)] + public string? oci { get; set; } + //کشور مقصد + [MaxLength(3)] + public string? dco { get; set; } + //شهر مقصد + [MaxLength(5)] + public string? dci { get; set; } + //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی فرستنده + [MaxLength(12)] + public string? tid { get; set; } + //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده + [MaxLength(12)] + public string? rid { get; set; } + //نوع بارنامه/ نوع حمل + public int? lt { get; set; } + //شماره ناوگان + [MaxLength(20)] + public string cno { get; set; } + //کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای( + [MaxLength(12)] + public string? did { get; set; } + //کالاهای حمل شده + public List sg { get { return new List(); } } + //شماره اعلامیه فروش + [MaxLength(20)] + public string? asn { get; set; } + //تاریخ اعلامیه فروش + public string? DateSaleAnnouncement { get; set; } + public int? asd { get { return 0; } } #endregion #region Navigation diff --git a/Back/Data/Models/InvoiceItem.cs b/Back/Data/Models/InvoiceItem.cs index d5ab882..9ae160d 100644 --- a/Back/Data/Models/InvoiceItem.cs +++ b/Back/Data/Models/InvoiceItem.cs @@ -135,6 +135,10 @@ namespace Back.Data.Models public decimal? pspd { get; set; } //عیار public decimal? cui { get; set; } + //نرخ خرید ارز + public decimal? cpr { get; set; } + //ماخذ مالیات بر ارزش افزوده در الگوی فروش ارز + public long? sovat { get; set; } #endregion #region Navigation diff --git a/Back/Services/PreparationTaxInvoice.cs b/Back/Services/PreparationTaxInvoice.cs new file mode 100644 index 0000000..5e0723d --- /dev/null +++ b/Back/Services/PreparationTaxInvoice.cs @@ -0,0 +1,126 @@ +using Back.Data.Models; +using Shared.DTOs; + +namespace Back.Services +{ + public class PreparationHeaderTaxInvoice + { + private readonly Invoice _invoice; + private readonly ActionTaxPayer _actionTaxPayer; + private readonly int level; + + public PreparationHeaderTaxInvoice(Invoice invoice, ActionTaxPayer actionTaxPayer) + { + _invoice = invoice; + _actionTaxPayer = actionTaxPayer; + level = _invoice.pattern.ID; + } + + #region Header + public string Taxid { get { return _actionTaxPayer.GenerateTaxid(_invoice.inno, _invoice.InvoiceDate.Replace("/", "").Trim()); } } + public long? Indatim { get { return _invoice.indatim ?? null; } } + public long? Indati2m { get { return _invoice.Indati2m ?? null; } } + public int? Inty { get { return _invoice.inty ?? 1; } } + public string? Inno { get { return string.IsNullOrEmpty(_invoice.inno) ? null : _invoice.inno; } } + public string? Irtaxid + { + get + { + return _invoice.invoiceType == InvoiceType.BackFrmSale || _invoice.invoiceType == InvoiceType.Repair ? _invoice.invoice.taxid + : _invoice.invoiceType == InvoiceType.Cancellation ? _invoice.taxid : null; + } + } + public int? Inp { get { return _invoice.inp ?? 1; } } + public int? Ins { get { return _invoice.ins ?? 1; } } + public string? Tins { get { return string.IsNullOrEmpty(_invoice.tins) ? null : _invoice.tins; } } + public int? Tob { get { return level == 10 ? null : _invoice.tob == 5 ? 1 : _invoice.tob == 6 ? 4 : _invoice.tob; } } + public string? Bid + { + get + { + return level == 10 || string.IsNullOrEmpty(_invoice.bid) || !string.IsNullOrEmpty(_invoice.tinb) + || _invoice.tob == 1 || _invoice.tob == 2 || _invoice.tob == 3 || _invoice.tob == 4 ? null : _invoice.bid}; + } + public string? Tinb { get { return level == 10 || string.IsNullOrEmpty(_invoice.tinb) || _invoice.tob == 5 || _invoice.tob == 6 ? null : _invoice.tinb; } } + public string? Sbc { get { return string.IsNullOrEmpty(_invoice.sbc) ? null : _invoice.sbc; } } + public string? Bpc + { + get + { + return level == 10 || string.IsNullOrEmpty(_invoice.bpc) || !string.IsNullOrEmpty(_invoice.tinb) + || _invoice.tob == 1 || _invoice.tob == 2 || _invoice.tob == 3 || _invoice.tob == 4 ? null : _invoice.bpc; + } + } + public string? Bbc { get { return level == 10 || string.IsNullOrEmpty(_invoice.bbc) ? null : _invoice.bbc; } } + public int? Ft { get { return level == 9 ? _invoice.ft : null; } } + public string? Bpn { get { return (level == 9 || level == 4) && !string.IsNullOrEmpty(_invoice.bpn) ? _invoice.bpn : null; } } + public string? Scln { get { return (level == 3 || level == 4) && !string.IsNullOrEmpty(_invoice.scln) ? _invoice.scln : null; } } + public string? Scc { get { return (level == 3 || level == 4 || level == 10) && !string.IsNullOrEmpty(_invoice.scc) ? _invoice.scc : null; } } + public string? Cdcn { get { return level == 10 ? _invoice.cdcn : null; } } + public int? Cdcd { get { return level == 10 ? _invoice.cdcd : null; } } + public string? Crn { get { return (level == 3 || level == 4 || level == 5 || level == 6) && !string.IsNullOrEmpty(_invoice.crn) ? _invoice.crn : null; } } + public string? Billid { get { return level == 8 ? _invoice.billid : null; } } + public decimal? Tprdis { get { return level == 10 ? null : _invoice.tprdis ?? null; } } + public decimal? Tdis { get { return level == 10 ? null : _invoice.tdis ?? null; } } + public decimal? Tadis { get { return level == 10 ? null : _invoice.tadis ?? null; } } + public decimal? Tvam { get { return _invoice.tvam ?? null; } } + public decimal? Todam { get { return _invoice.todam ?? null; } } + public decimal? Tbill { get { return -10 /* result.tbill ?? null*/; } } + public decimal? Tonw { get { return level == 10 ? _invoice.tonw : null; } } + public decimal? Torv { get { return level == 10 ? _invoice.torv : null; } } + public decimal? Tocv { get { return level == 10 ? _invoice.tocv : null; } } + public int? Setm { get { return level == 8 || level == 10 || level == 11 || level == 13 || _invoice.setm == 0 ? null : _invoice.setm ?? null; } } + public decimal? Cap { get { return level == 8 || level == 10 || level == 11 || level == 13 ? null : _invoice.cap ?? null; } } + public decimal? Insp { get { return level == 8 || level == 10 || level == 11 || level == 13 ? null : _invoice.insp ?? null; } } + public decimal? Tvop { get { return level == 8 || level == 10 || level == 11 || level == 13 ? null : _invoice.tvop ?? null; } } + public decimal? Tax17 { get { return level == 10 || string.IsNullOrEmpty(_invoice.seventeentax) ? null : Convert.ToDecimal(_invoice.seventeentax); } } + public string? Tinc { get { return level == 9 && !string.IsNullOrEmpty(_invoice.tinc) ? _invoice.tinc : null; } } + #endregion + + } + public class PreparationBodyTaxInvoice + { + private readonly InvoiceItem bitem; + private readonly int level; + + public PreparationBodyTaxInvoice(InvoiceItem bitem, int level) + { + this.bitem = bitem; + this.level = level; + } + public string? Sstid { get { return bitem.sstid; } } + public string? Sstt { get { return bitem.sstt; } } + public decimal? Am { get { return level == 4 ? null : bitem.am; } } + public string? Mu { get { return level == 4 || string.IsNullOrEmpty(bitem.mu) ? null : bitem.mu; } } + public decimal? Nw { get { return level == 10 ? bitem.nw : null; } } + public decimal? Fee { get { return level == 4 ? null : bitem.fee; } } + public decimal? Cfee { get { return bitem.cfee == 0 || level == 8 || level == 10 ? null : bitem.cfee; } } + public string? Cut { get{ return level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut; } } + public decimal? Exr { get { return level == 8 ? null : bitem.exr; } } + public decimal? Ssrv { get { return level == 10 ? bitem.ssrv : null; } } + public decimal? Sscv { get { return level == 10 ? bitem.sscv : null; } } + public decimal? Prdis { get { return level == 10 ? null : bitem.prdis; } } + public decimal? Dis { get { return level == 10 ? null : bitem.dis; } } + public decimal? Adis { get { return level == 10 ? null : bitem.adis; } } + public decimal? Vra { get { return bitem.vra; } } + public decimal? Vam { get { return bitem.vam; } } + public string? Odt { get { return string.IsNullOrEmpty(bitem.odt) ? null : bitem.odt; } } + public decimal? Odr { get { return bitem.odr; } } + public decimal? Odam { get { return bitem.odam; } } + public string? Olt { get { return string.IsNullOrEmpty(bitem.olt) ? null : bitem.olt; } } + public decimal? Olr { get { return bitem.olr; } } + public decimal? Olam { get { return bitem.olam; } } + public decimal? Consfee { get { return level == 5 || level == 13 ? bitem.consfee : null; } } + public decimal? Spro { get { return level == 5 || level == 13 ? bitem.spro : null; } } + public decimal? Bros { get { return level == 5 || level == 13 ? bitem.bros : null; } } + public decimal? Tcpbs { get { return level == 5 || level == 13 ? bitem.tcpbs : null; } } + public decimal? Cop { get { return level == 8 || level == 10 || level == 11 || level == 13 ? null : bitem.cop; } } + public decimal? Vop { get { return level == 8 || level == 10 || level == 11 || level == 13 ? null : bitem.vop; } } + public string? Bsrn { get { return string.IsNullOrEmpty(bitem.bsrn) ? null : bitem.bsrn; } } + public decimal? Tsstam { get { return bitem.tsstam; } } + public decimal? Cui { get { return level == 5 || level == 13 ? bitem.cui : null; } } + public decimal? Cpr { get { return null; } } + public long? Sovat { get { return bitem.sovat; } } + + } +}